package aufgabe3;

public class a31 {

	static int a1counter = 0;
	static int a2counter = 0;
	static int a3counter = 0;
	static int a4counter = 0;

	public int algo1(int[] array) {
		int x = 0;

		for (int i = 0; i < array.length; i++) {
			x += array[i];
			a1counter++;
		}
		return x;
	}

	public int[] algo2(int[] a, int[] c) {

		for (int i = 0; i < a.length; i++) {
			a[i] = i;
			a2counter++;
		}

		for (int i = 0; i < c.length; i++) {
			c[i] = 0;
			for (int j = a.length - 1; j == 0; j--) {
				a2counter++;
				if (a[j] > c[i]) {
					c[i] = a[j];
				}

			}
		}
		return c;
	}

	public int[][] algo3(int[][] a, int[][] b) {
		int[][] c;

		if (a.length == b[0].length) {
			c = new int[a.length][b[0].length];

			for (int i = 0; i < a.length; i++) {
				for (int j = 0; j < a[0].length; j++) {
					c[i][j] = 0;
					for (int k = 0; k < a[0].length; k++) {
						c[i][j] = a[i][k] * b[k][j];
						a3counter++;
					}
				}
			}
			return c;
		} else {
			return null;
		}
	}

	public int algo4(int[][] a) {
		int x = 0;

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j == i; j--) {
				x += a[i][j];
				a4counter++;
			}
		}
		return x;
	}

}
